var api = require('../../utils/api.js');
var app = getApp();
var cleartime;
Page({

    /**
     * 页面的初始数据
     
     */
    data: {
        merchs:[],
        merch:'',
        array:['剩余时间最少','剩余时间最多','产品最多','产品最少','按照创建时间'],
        order:'',
        page:1,
        list:[],
        endtime:'',
        startime:'',
        year:''
    },
    onYearChange(ret){
        console.log(ret);
        this.setData({
            year:ret.detail.value,
        })
        this.gettypes();
    },
    onLoad(ret){
        this.setData({
            caseid:ret.id
        })
        var that=this;
        this.getlist();
    },

    onReachBottom(){
        console.log('++++')
        
        wx.showLoading({
            title:'加载中..'
        })
        this.getlist();
       
    },

    onShow() {
        var that = this;
      

        let user = wx.getStorageSync('user');
        if (!user) {
            wx.navigateTo({
                url: '/pages/login/login'
            });
        }


    },


 
 
    bindDateChangea(ret){
        console.log(ret);
        this.setData({
            startime:ret.detail.value,
            page:1,
            list:[]
        })
        this.getlist();
    },
    bindDateChangeb(ret){
        console.log(ret);
        this.setData({
            endtime:ret.detail.value
        })
        this.setData({
            page:1,
            list:[]
        })
        this.getlist();
    },

        /** 
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
    },
    onUnload: function () { // 关闭清除定时器
        const self = this
    },




    getlist(){

   

        var page=this.data.page;
        var that=this;
        var oldlist=this.data.list;
        var caseid=this.data.caseid;
        this.setData({
            page:page+1
        })
        api.post({
            url: 'neworder/getmycasesc',
            data: {qid:caseid,page:page},
            success: data => {
                var list = data.data;

                if(list.length>0){
                    list.forEach(function (index) {
                        oldlist.push(index);
                    })
                }

                wx.hideLoading();

                that.setData({
                    list: oldlist
                })
              
            
            }
        })

    },

  
    nexturl(ret){
        console.log(ret);
        var url=ret.currentTarget.dataset.url;

        wx.navigateTo({
          url: url
        })

    }
})